import 'package:flutter/material.dart';

/// @date 2020/08/06  10:59
/// @author 程志强
/// @des 单一方向拖动

class GestureDragVertical extends StatefulWidget {
  @override
  _GestureDragVerticalState createState() => _GestureDragVerticalState();
}

class _GestureDragVerticalState extends State<GestureDragVertical> {
  // 距离顶部的偏移
  double _top = 0.0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("拖拽、滑动(单一方向)"),
      ),
      body: Stack(
        children: <Widget>[
          Positioned(
            top: _top,
            child: GestureDetector(
              child: CircleAvatar(
                child: Text("A"),
              ),
              onVerticalDragUpdate: (DragUpdateDetails e) {
                setState(() {
                  _top += e.delta.dy;

                });
              },
            ),
          )
        ],
      ),
    );
  }
}
